package xyz.zeer.endangeredanimal;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class HomeActivity extends AppCompatActivity{

    BottomNavigationView yrs_bottomNavigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.yrs_activity_home);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,new HomeFragment()).commit();
        yrs_bottomNavigationView = findViewById(R.id.bottom_nav);
        yrs_bottomNavigationView.setOnNavigationItemSelectedListener(selectedListener);
    }

    private BottomNavigationView.OnNavigationItemSelectedListener selectedListener =
            item -> {
                Fragment selectedFragment = null;
                switch (item.getItemId())
                {
                    case R.id.yrs_nav_home:
                        selectedFragment = new HomeFragment();
                        break;
                    case R.id.yrs_nav_threat:
                        selectedFragment = new ThreatFragment();
                        break;
                    case R.id.yrs_nav_protect:
                        selectedFragment = new ProtectFragment();
                        break;
                    case R.id.yrs_nav_other:
                        selectedFragment = new OtherFragment();
                        break;
                }
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, selectedFragment).commit();
                return true;
            };
}
